﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Excell_On_Services.ViewModels.CartIndexViewModel>" %>

<h2>Your cart : </h2>
     <table width="98%" align="center" cellpadding="5" cellspacing="5" border="5">
        <thead>
            <tr>
                <th align="left">Service</th>
                <th align="center">Price</th>
                <th align="center">Quantity</th>
                <th align="left">Start Date</th>
                <th align="left">End Date</th>
                <th align="center">Subtotal</th>
            </tr>
        </thead>
        <tbody>
            <% foreach(var line in Model.Cart.Lines) { %>
                <tr>
                    <% using (Html.BeginForm("UpdateCart", "Cart"))
                       { %>
                    <td align="left"><%: line.Service.Name%></td>
                    <td align="right"><%: line.Service.Price.ToString("c")%></td>
                    <%--<td align="center"><%: Html.TextBox("txtQuantily", line.Quantity, new {@class = "control_input", maxlength = 4 })%></td>--%>
                    <td align="center"><%: Html.TextBox("NewQuantity", line.Quantity, new { @class = "control_input", style="width: 40px;" })%></td>
                    <td align="left"><%: Html.TextBox("NewStartDate", line.StartDate.ToShortDateString(), new { @class = "control_input", style = "width: 150px;", onclick = "displayDatePicker('NewStartDate', this);" })%></td>
                    <td align="left"><%: Html.TextBox("NewEndDate", line.EndDate.ToShortDateString(), new { @class = "control_input", style = "width: 150px;",onclick = "displayDatePicker('NewEndDate', this);" })%></td>
                    <td align="right">
                        <%: (line.Quantity * line.Service.Price * (long)((TimeSpan)(line.EndDate - line.StartDate)).TotalDays).ToString("c")%>
                    </td>
                    <td align="right">
                        <%--<a href="<%: Url.Action("UpdateCart", new {serviceID = line.Service.ServiceID}) %>" title="Update Card" >Update </a>--%>
                         <%: Html.Hidden("ServiceID", line.Service.ServiceID)%>
                        <input type="submit" value="Update" class="button_order" />
                    </td>
                    <% } %>
                    <td align="right">
                         <% using (Html.BeginForm("RemoveFromCart", "Cart"))
                            { %>
                            <%: Html.Hidden("ServiceID", line.Service.ServiceID)%>
                            <%: Html.HiddenFor(x => x.ReturnUrl)%>
                            <input type="submit" value="Remove" class="button_order" />
                        <% } %>
                    </td>
                    
                    
                </tr>
            <% } %>
        </tbody>
        <tfoot>
            <tr>
                <td colspan="8"></td>
            </tr>
            <tr>
                <td colspan="5" align="right"><h2>Total:</h2></td>
                <td align="right">
                    <b><%: Model.Cart.ComputeTotalValue().ToString("c") %></b>
                </td>
                <td align="right" colspan="2"><a class="button_user" href="<%: Url.Action("CompleteOrder","Cart") %>" title="Commit Order" > Commit Order </a></td>
            </tr>
        </tfoot>
    </table>
    <p align="center">
        

    </p>

    <p align="center" class="actionButtons">
        
        
        
    </p>
